package com.pw.study.client;

import com.alibaba.otter.canal.client.CanalConnector;
import com.alibaba.otter.canal.client.CanalConnectors;
import com.alibaba.otter.canal.protocol.Message;
import com.pw.study.handler.MessageHandler;

import java.net.InetSocketAddress;

public class CanalClient {
    public static void main(String[] args) throws InterruptedException {
        CanalConnector canalConnector = CanalConnectors.newSingleConnector(new
                InetSocketAddress("hadoop112", 11111), "example", null, null);
        canalConnector.connect();
        canalConnector.subscribe("0924.order_info");
        while (true){

            Message message = canalConnector.get(100);
            if(message.getId()==-1){
                System.out.println("当前没有数据。。。。。");
                Thread.sleep(1000*5);
                continue;
            }
            //处理数据
            MessageHandler.doDataDeal(message);

        }

    }

}
